<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
{literal}
/* popup_box DIV-Styles*/
#popup_box { 
	display:none; /* Hide the DIV */
	position:fixed;  
	_position:absolute; /* hack for internet explorer 6 */  
	height:300px;  
	width:400px;  
	background:#FFFFFF;  
	left: 300px;
	top: 150px;
	z-index:100; /* Layering ( on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
	margin-left: 15px;  
	
	/* additional features, can be omitted */
	border:2px solid #ffffff;  	
	padding:15px;  
	font-size:15px;  
	-moz-box-shadow: 0 0 5px #ff0000;
	-webkit-box-shadow: 0 0 5px #ff0000;
	box-shadow: 0 0 10px #123456;
	
}



a{  
cursor: pointer;  
text-decoration:none;  
} 

/* This is for the positioning of the Close Link */
#popupBoxClose {
	font-size:20px;  
	line-height:15px;  
	right:5px;  
	top:5px;  
	position:absolute;  
	color:#6fa5e2;  
	font-weight:500;  	
}
{/literal}
</style>
<link rel="stylesheet" type="text/css" href="css/flexigrid.css" />
<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/flexigrid.js"></script>
<script type="text/javascript">
{literal}

		function loadPopupBox() 
		{	// To Load the Popupbox
			$('#popup_box').fadeIn("slow");
				
		}
		
		function unloadPopupBox() 
		{	// TO Unload the Popupbox
			$('#popup_box').fadeOut("slow");
			
		}	
		function doClick()
		{
			
			var form1 = document.d1;
			var pid = document.getElementById("productID").value;
			
			var r = /^[0-9]*[1-9][0-9]*$/;　
			if(r.test(form1.number.value))
				{
				  itemlist = pid+","+ form1.number.value;
				
				  $.ajax({
				   type: "POST",
				   dataType: "json",
				   url: "?act=product.modify_quantity",
				   data: "items="+itemlist,
				   success: function(){
				   unloadPopupBox();
				   alert("补货成功！");
				  
				   $("#flex1").flexReload();
				   }
				 });
				  
				}
			else alert("请输入正确格式");
			
		
			
			
		}


$(document).ready(function(){
	
	$("#flex1").flexigrid
			(
			{
				url: '?act=product.stockout_list_show',
				dataType: 'json',

			colModel : [
				{display: 'ID', name : 'ID', width : 40, sortable : true, align: 'center'},
				{display: 'Name', name : 'Name', width : 240, sortable : true, align: 'center'},
				{display: 'Publisher', name : 'Publisher', width : 200, sortable : true, align: 'left'},
				{display: 'Quantity', name : 'Quantity', width : 40, sortable : true, align: 'left'},
				{display: 'Price', name : 'Price', width : 40, sortable : true, align: 'left'},
				{display: 'Category', name : 'Category', width : 180, sortable : true, align: 'left'},
				{display: 'ISBN', name : 'ISBN', width : 200, sortable : true, align: 'left'},
				
				
				],
			buttons : [
				{name: 'Add', bclass: 'add', onpress : test},
				{name: 'Export', bclass: 'export', onpress : test}
				],
				searchitems : [
								
								{display: 'Name', name : 'a.Name', isdefault: true},
								{display: 'Publisher', name : 'Publisher'}
								],
			sortname: "id",
			sortorder: "asc",
			usepager: true,
			title: '缺货信息',
			useRp: true,
			rp: 20,
			showTableToggleBtn: true,
			width: 'auto',
			height: 'auto',
			procmsg: '正在获取数据，请稍候 ...'  
			}
			);   
	
});
function sortAlpha(com)
{ 
    jQuery('#flex1').flexOptions({newp:1, params:[{name:'letter_pressed', value: com},{name:'qtype',value:$('select[name=qtype]').val()}]});
    jQuery("#flex1").flexReload(); 
}

function test(com,grid)
{
    if (com=='Add')
        {
           if($('.trSelected',grid).length==1)
           {
		   if(confirm('确认补充《'+$('.trSelected',grid).find("td").eq(1).text()+'》货源？')){
              
			   var pid = document.getElementById("productID");
			   pid.value = $('.trSelected',grid).find("td").eq(0).text();
              // alert(pid.value);
			   loadPopupBox();       	
			}
			
           }
           else if($(".trSelected").length==0){  
                alert("请选择一个您要补充的记录");  
            }  
           else if($(".trSelected").length>1){  
               alert("请每次补充单个商品");  
           }  
        }
    else if (com=='Export')
	{
		window.open("?act=product.export_stockout_product");
	}
           
} 
{/literal}
</script>
<title>Insert title here</title>
</head>
<body>
<div>
<table id="flex1" style="display:none"></table>
</div>
<div id="popup_box">	<!-- OUR PopupBox DIV-->
	<h1>增加库存</h1>
	<form name="d1" action="?act=product.modify_quantity" method='post'>
<table>
<tr><td>
<input type="hidden" id="productID" value=""/>
</td>
</tr>
<tr>
<td>增加数量：</td>
<td><input type="text" value="" name="number"></input></td>
</tr>
</table>
<br>
<br>	
	<input type="button" value="提交" onClick="doClick();">
	</form>
	<a id="popupBoxClose" onClick="unloadPopupBox()">Close</a>	
</div>
</body>
</html>